from django.db import models


# Create your models here.
class BaseModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        abstract = True


class Roles(BaseModel):
    roles_name = models.CharField(max_length=48, verbose_name='职业')

    class Meta:
        db_table = 'Role'

    def __str__(self):
        return self.roles_name


class User(BaseModel):
    username = models.CharField(max_length=48, verbose_name='用户名')
    password = models.CharField(max_length=128, verbose_name='密码')
    role = models.ForeignKey(Roles, on_delete=models.CASCADE, null=True, blank=True)

    class Meta:
        db_table = 'User'

    def __str__(self):
        return self.username


class Cate(BaseModel):
    name = models.CharField(max_length=48, verbose_name='分类名称')

    class Meta:
        db_table = 'Cate'

    def __str__(self):
        return self.name
